#include "model.h"
#include "ui_model.h"
#include <QPushButton>
#include "exercise.h"
#include <QDebug>
#include "test.h"


int grade=0;

Model::Model(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Model)
{
    ui->setupUi(this);
    extern int model;
    //打开练习模式：
    if(model==1)
    {
        //grade为年级指示标志
        connect(ui->pbtn1,&QPushButton::clicked,this,[&](){
            grade=1;
            Exercise *exer = new Exercise();
            exer->show();
            exer->setAttribute(Qt::WA_DeleteOnClose);
        });
        connect(ui->pbtn2,&QPushButton::clicked,this,[&](){
            grade=2;
            Exercise *exer = new Exercise();
            exer->show();
            exer->setAttribute(Qt::WA_DeleteOnClose);
        });
        connect(ui->pbtn3,&QPushButton::clicked,this,[&](){
            grade=3;
            Exercise *exer = new Exercise();
            exer->show();
            exer->setAttribute(Qt::WA_DeleteOnClose);
        });
        connect(ui->pbtn4,&QPushButton::clicked,this,[&](){
            grade=4;
            Exercise *exer = new Exercise();
            exer->show();
            exer->setAttribute(Qt::WA_DeleteOnClose);
        });
        connect(ui->pbtn5,&QPushButton::clicked,this,[&](){
            grade=5;
            Exercise *exer = new Exercise();
            exer->show();
            exer->setAttribute(Qt::WA_DeleteOnClose);
        });
    }
    //打开考试模式：
    if(model==2)
    {
        connect(ui->pbtn1,&QPushButton::clicked,this,[&](){
            grade=1;
            Test *tes = new Test();
            tes->show();
            tes->setAttribute(Qt::WA_DeleteOnClose);
        });
        connect(ui->pbtn2,&QPushButton::clicked,this,[&](){
            grade=2;
            Test *tes = new Test();
            tes->show();
            tes->setAttribute(Qt::WA_DeleteOnClose);
        });
        connect(ui->pbtn3,&QPushButton::clicked,this,[&](){
            grade=3;
            Test *tes = new Test();
            tes->show();
            tes->setAttribute(Qt::WA_DeleteOnClose);
        });
        connect(ui->pbtn4,&QPushButton::clicked,this,[&](){
            grade=4;
            Test *tes = new Test();
            tes->show();
            tes->setAttribute(Qt::WA_DeleteOnClose);
        });
        connect(ui->pbtn5,&QPushButton::clicked,this,[&](){
            grade=5;
            Test *tes = new Test();
            tes->show();
            tes->setAttribute(Qt::WA_DeleteOnClose);
        });
    }
    //qDebug()<<model;






}

Model::~Model()
{
    delete ui;
}
